.code16
.global _start

_start:
	cli
	//movw	$0x0000, %cs
	movw	$0x7c00, %sp
	call	print_hello_string
	call	rwl
	jmp 	_start /* auto reset */

rwl:	/* read write (one char) loop */
	movb	$0x10, %ah
	int	$0x16
	/* now char code is in %al in %ah san-code */
	cmpb	$0x30, %al
	je	rwl_end
	movb	$0x0e, %ah
	int	$0x10
	jmp 	rwl

	rwl_end:
		ret

print_hello_string:
	push	%cs
	pop	%es
	movw 	$0x1301, %ax
	movb	$0x05, %dh
	movb 	$0x10, %dl
	movb	$0x00, %bh
	movb	$0x05, %bl
	movw	$(_d_hello_string_s-_d_hello_string), %cx
	movw	$_d_hello_string, %bp
	int	$0x10
	ret

. = _start + 0x0050
_d_hello_string:
	.ascii	"Hello, qemu! > "
_d_hello_string_s:
	.byte	_d_hello_string - _d_hello_string_s
	.set 	_D_HELLO_STRING_S, _d_hello_string_s - _d_hello_string
	.byte 0x00

. = _start + 510
.word 0xaa55
